package com.boot.config;


import com.boot.exceptionHandler.ssmInterceptor;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;

@Configuration
//配置handlerMapping和handlerAdapter
@EnableWebMvc
//扫描包的位置
@ComponentScan(basePackages = {"com.boot.controller","com.boot.exceptionHandler"})
public class WebMvcJavaConfig implements WebMvcConfigurer {

    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        registry.jsp("/WEB-INF/views/", ".jsp");
    }

    //静态资源显示
    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new ssmInterceptor()).addPathPatterns("/**");
    }
}
